package com.jstyle.jclife.adapter;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.jstyle.jclife.R;
import com.jstyle.jclife.model.StepData;
import com.jstyle.jclife.utils.DateUtil;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2018/7/12.
 */

public class HistoryStepWeekAdapter extends RecyclerViewBaseAdapter {

    public HistoryStepWeekAdapter(List<StepData> stepDataList) {
        super(stepDataList);
    }

    @SuppressLint("SetTextI18n")
    @Override
    protected void bindData(BaseViewHolder holder, int position) {
        HistoryStepWeekViewHolder historyStepWeekViewHolder=(HistoryStepWeekViewHolder)holder;
        StepData stepData= (StepData) mDataList.get(position);
        Context context=historyStepWeekViewHolder.itemView.getContext();
        historyStepWeekViewHolder.tvHistoryWeekDate.setText(DateUtil.getShowDay(context,stepData.getDate()));
        String step=stepData.getStep();

        historyStepWeekViewHolder.tvHistoryWeekStep.setText(String.valueOf(step)+" "+context.getString(R.string.Step));
        historyStepWeekViewHolder.tvHistoryWeekProgress.setText(String.format(context.getString(R.string.Target_format),stepData.getGoal()));
        historyStepWeekViewHolder.progressBarHistoryWeek.setProgress(Integer.valueOf(stepData.getGoal()));


    }

    @Override
    protected int getLayoutId(int viewType) {
        return R.layout.item_history_step_bottom;
    }

    class HistoryStepWeekViewHolder extends BaseViewHolder {
        @BindView(R.id.tv_history_week_date)
        TextView tvHistoryWeekDate;
        @BindView(R.id.tv_history_week_step)
        TextView tvHistoryWeekStep;
        @BindView(R.id.progressBar_history_week)
        ProgressBar progressBarHistoryWeek;
        @BindView(R.id.tv_history_week_progress)
        TextView tvHistoryWeekProgress;

        public HistoryStepWeekViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this,itemView);
        }
    }

    @Override
    public BaseViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(getLayoutId(viewType), parent, false);
        BaseViewHolder baseViewHolder = new HistoryStepWeekViewHolder(view);
        return baseViewHolder;
    }
}
